home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group01b.txt / 000140_icon-group-sender_Mon Sep 3 19:28:47 2001.msg < prev    next >
Internet Message Format  |  2002-01-03  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id f842RCE25262
  4.     for icon-group-addresses; Mon, 3 Sep 2001 19:27:12 -0700 (MST)
  5. Message-Id: <200109040227.f842RCE25262@baskerville.CS.Arizona.EDU>
  6. Date: Mon, 03 Sep 2001 11:07:37 +1100
  7. From: dodod <dodo@hotmail.com>
  8. X-Accept-Language: en
  9. X-Newsgroups: comp.lang.icon
  10. Subject: Re: join
  11. To: icon-group@cs.arizona.edu
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13. Status: RO
  14. Content-Length: 1712
  15.  
  16. thanks 
  17.  
  18.  
  19. Andrew Hamm wrote:
  20. > dodod wrote in message <3B8C3D59.AA150BB8@hotmail.com>...
  21. > >hello
  22. > >i would like to write a program to emulate
  23. > >unix join command but i do not know how to start
  24. > >can you give me a hint or an example ?
  25. > >
  26. > possibly start by coding a function which can be used in a coroutine. This
  27. > function's job is to suspend with a line from a text file. When used in a
  28. > coroutine, it could be activated with a parameter which tells it to either
  29. > yield the current line or the next line. In other words, the coroutine could
  30. > be used to provide look-ahead or actual read of next line.
  31. > Then, start two separate coroutines using this function, applied to the two
  32. > different files. Your main loop could peek at each line, and if it matches,
  33. > perform the join otherwise move on. Since the rule in UNIX join is that the
  34. > lines must be presented in "increasing collating sequence" (ie sorted on the
  35. > key field) then depending on the relative << == or >> of the key fields on
  36. > the line, you activate one or the other coroutines to read the next line
  37. > from either or both files.
  38. > Hmm - now that I think about it, I dont think the coroutine function needs
  39. > to offer look-ahead, and therefore doesn't need the activation flag.
  40. > Activate both coroutines prior to the start of your loop, store the results
  41. > in a local buffer, and ask for the next row as needed as you progress.
  42. > I suppose it could also be programmed without the use of coroutines, but
  43. > where's the fun in that?
  44. > --
  45. > Space Corps Directive #349
  46. > Any officer found to have been slaughtered and replaced by a shape-changing
  47. > chameleonic life form shall forfeit all pension rights.
  48. >     -- Red Dwarf
  49.